package cn.edu.xmu.orderpayment.payment.model.bo;
import lombok.Data;
import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.Map;

/**
 * @author YuJie
 * @date 2021-12-12
 */
@Data
public class PayPattern {
    private Long id;
    private String name;
    private Byte state;
    private LocalDateTime beginTime;
    private LocalDateTime endTime;
    private String className;
    private Long creatorId;
    private String creatorName;
    private Long modifierId;
    private String modifierName;
    private LocalDateTime gmtCreate;
    private LocalDateTime gmtModified;

    public State getState() {
        return State.getStateByCode(Integer.valueOf(state));
    }
    public void setState(State state) {
        this.state = state.getCode().byteValue();
    }


    public enum State {
        STOPPED(0, "不可用"),
        USABLE(1, "可用");
        private static final Map<Integer, State> STATE_MAP;
        static {
            STATE_MAP = new HashMap();
            for (State enum1 : values()) {
                STATE_MAP.put(enum1.code, enum1);
            }
        }
        private int code;
        private String description;
        State(int code, String description) {
            this.code = code;
            this.description = description;
        }
        public static State getStateByCode(Integer code) {
            return STATE_MAP.get(code);
        }
        public Integer getCode() {
            return code;
        }
        public String getDescription() {
            return description;
        }
    }
}
